<html>
<head>
<style type='text/css'>
body {
   background-color: white;
   margin: 1em 2em 1em 2em;
   font-family: Sans-Serif;
   color: #002;
   line-height: 140%;
   font-size: 12px;
}

h1 {
    font-size: 140%;
}

h2 {
    font-size: 130%;
}

h3 {
    font-size: 120%;
}

h4 {
    font-size: 100%;
    font-style: normal;
    font-weight: bold;
}

h5 {
    font-size: 100%;
    font-style: italic;
    font-weight: normal;
}

pre {
   background-color: #eee;
   padding: 0.5em 0.5em 0.5em 2em;
}

@media print {
   pre {word-wrap:break-word; width:100%;}
} 

ul li,
ol li {
   padding-left: 0.3em;
   /*text-indent: -2em;*/
   margin-bottom: 0.5em;
}

em {
   font-style: normal;
   font-weight: bold;
   text-decoration: underline;
   color: #c40;
}

code {
   font-family: Monospace;
   font-size: 100%;
   color: #c40;
}

a, a * {
   text-decoration: underline;
   color: #14a0d1;
   /* border: 0.5px solid #aaa;
   white-space: nowrap;
   padding-right: 0.1em;
   padding-left: 0.1em;
   padding-bottom: -5px; */
}

a code {
   color: #14a0d1;
}

img {
   position: relative;
   bottom: -4px;
}

div.headline {
   font-weight: bold;
   font-size: 110%;
}

div.copyright {
   margin-top: 1em;
   border-top: 1px solid black;
   padding-top: 0.5em;
}

div.iris_headline {
   border-bottom: 1px solid black;
   padding-bottom: 0.3em;
}

.LaTeX {
   font-family: Monospace;
   font-size: 100%;
   border: 1px solid #060;
   color: #060;
}

code.LaTeX {
   background-color: white;
   padding: 0.5em 0.5em 0.5em 2em;
}
</style>
</head>

<body>
<div class="iris_headline">IRIS Toolbox Reference Manual</div>




<h2 id="dbplot/dbplot">dbplot</h2>
<div class="headline">Plot from database</div>

<h4 id="syntax">Syntax</h4>
<pre><code>[FF,AA,PDb] = dbplot(D,List,Range,...)
[FF,AA,PDb] = dbplot(D,Range,List,...)
[FF,AA,PDb] = dbplot(D,List,...)
[FF,AA,PDb] = dbplot(D,Range,...)
[FF,AA,PDb] = dbplot(D,...)</code></pre>
<h4 id="input-arguments">Input arguments</h4>
<ul>
<li><p><code>D</code> [ struct ] - Database with input data.</p></li>
<li><p><code>List</code> [ cellstr | rexp ] - List of expressions (or labelled expressions) that will be evaluated and plotted in separate graphs; if not specified, all time series name found in the input database <code>D</code> will be plotted. Alternatively, <code>List</code> can be a regular expression (rexp object), which will be matched against all time series names in the input database.</p></li>
<li><p><code>Range</code> [ numeric ] - Date range; if not specified, the function <a href="../dbase/dbrange.html"><code>dbrange</code></a> will be used to determined the plotted range (same for all graphs).</p></li>
</ul>
<h4 id="output-arguments">Output arguments</h4>
<ul>
<li><p><code>FF</code> [ numeric ] - Handles to figures created by <code>qplot</code>.</p></li>
<li><p><code>AA</code> [ cell ] - Handles to axes created by <code>qplot</code>.</p></li>
<li><p><code>PDB</code> [ struct ] - Database with actually plotted series.</p></li>
</ul>
<h4 id="options">Options</h4>
<ul>
<li><p><code>'addClick='</code> [ <em><code>true</code></em> | <code>false</code> ] - Make axes expand in a new graphics figure upon mouse click.</p></li>
<li><p><code>'captions='</code> <span class="citation">[ cellstr | @comment | *empty* ]</span> - Strings that will be used for titles in the graphs that have no title in the q-file.</p></li>
<li><p><code>'clear='</code> [ numeric | <em>empty</em> ] - Serial numbers of graphs (axes objects) that will not be displayed.</p></li>
<li><p><code>'dbSave='</code> [ cellstr | <em>empty</em> ] - Options passed to <code>dbsave</code> when <code>'saveAs='</code> is used.</p></li>
<li><p><code>'deviationsFrom='</code> [ numeric | <em>empty</em> ] - Each expression in <code>List</code> that starts with a <code>@</code> or <code>#</code> (see Description) will be reported in deviations from this specified date.</p></li>
<li><p><code>'deviationsTimes='</code> [ numeric | <em>empty</em> ] - Used only if <code>'deviationsFrom='</code> is non-empty; each expression in <code>List</code> that starts with a <code>@</code> or <code>#</code> (see Description) will be reported in deviations multiplied by this number.</p></li>
<li><p><code>'drawNow='</code> [ <code>true</code> | <em><code>false</code></em> ] - Call Matlab <code>drawnow</code> function upon completion of all figures.</p></li>
<li><p><code>'grid='</code> [ <em><code>true</code></em> | <code>false</code> ] - Add grid lines to all graphs.</p></li>
<li><p><code>'highlight='</code> [ numeric | cell | <em>empty</em> ] - Date range or ranges that will be highlighted.</p></li>
<li><p><code>'interpreter='</code> [ <em><code>'latex'</code></em> | 'none' ] - Interpreter used in graph titles.</p></li>
<li><p><code>'mark='</code> [ cellstr | <em>empty</em> ] - Marks that will be added to each legend entry to distinguish individual columns of multivariated tseries objects plotted.</p></li>
<li><p><code>'maxPerFigure='</code> [ numeric | <em><code>36</code></em> ] - Maximum number of graphs in one figure window; if the actual graph count exceeds <code>maxPerFigure</code>, the option '<code>subplot=</code>' is adjusted automatically, and new figure windows are opened as needed.</p></li>
<li><p><code>'overflow='</code> [ <code>true</code> | <em><code>false</code></em> ] - Open automatically a new figure window if the number of subplots exceeds the available total; <code>'overflow='false</code> means an error will occur instead.</p></li>
<li><p><code>'plotFunc='</code> <span class="citation">[ @bar | @hist | *@plot* | @plotcmp | @plotpred | @stem | cell ]</span> - Plot function used to create the graphs; use a cell array, <code>{plotFunc,...}</code> to specify extra input arguments that will be passed into the plotting function.</p></li>
<li><p><code>'prefix='</code> [ char | <em><code>'P%g_'</code></em> ] - Prefix (a <code>sprintf</code> format string) that will be used to precede the name of each entry in the <code>PDb</code> database.</p></li>
<li><p><code>'round='</code> [ numeric | <em><code>Inf</code></em> ] - Round the input data to this number of decimals before plotting.</p></li>
<li><p><code>'saveAs='</code> [ char | <em>empty</em> ] - File name under which the plotted data will be saved either in a CSV data file or a PS graphics file; you can use the <code>'dbsave='</code> option to control the options used when saving CSV.</p></li>
<li><p><code>'style='</code> [ struct | <em>empty</em> ] - Style structure that will be applied to all figures and their children created by the <code>qplot</code> function.</p></li>
<li><p><code>'subplot='</code> [ <em>'auto'</em> | numeric ] - Default subplot division of figures, can be modified in the q-file.</p></li>
<li><p><code>'sstate='</code> [ struct | model | <em>empty</em> ] - Database or model object from which the steady-state values referenced to in the quick-report file will be taken.</p></li>
<li><p><code>'style='</code> [ struct | <em>empty</em> ] - Style structure that will be applied to all created figures upon completion.</p></li>
<li><p><code>'transform='</code> [ function_handle | <em>empty</em> ] - Function that will be used to trans</p></li>
<li><p><code>'tight='</code> [ <code>true</code> | <em><code>false</code></em> ] - Make the y-axis in each graph tight.</p></li>
<li><p><code>'vLine='</code> [ numeric | <em>empty</em> ] - Dates at which vertical lines will be plotted.</p></li>
<li><p><code>'zeroLine='</code> [ <code>true</code> | <em><code>false</code></em> ] - Add a horizontal zero line to graphs whose y-axis includes zero.</p></li>
</ul>
<h4 id="description">Description</h4>
<p>The function <code>dbplot</code> opens a new figure window (as many as needed to accommodate all graphs given the option <code>'subplot='</code>), and creates a graph for each entry in the cell array <code>List</code>.</p>
<p><code>List</code> can contain either the names of database fields, or expressions referring to database fields; these expressions will be then evaluated in the input database context. You can also add labels (that will be displayed as graph titles) enclosed in double quotes and preceding the expressions. Alternatively, you can specify titles through the option <code>'captions='</code>. At the beginning of the expression, you can use one of the following marks:</p>
<ul>
<li><p><code>^</code> (a hat symbol) means the function specified in the option <code>'transform='</code> will not be applied to that expression;</p></li>
<li><p><code>@</code> (an at symbol) in combination with the option <code>'deviationFrom='</code> means that the deviations will reported in multiplicative form (i.e. the actual value divided by the base period value).</p></li>
<li><p><code>#</code> (a hash symbol) in combination with the option <code>'deviationFrom='</code> means that the deviations will reported in additive form (i.e. the actual value minus the base period value).</p></li>
</ul>
<h4 id="example">Example</h4>
<p>The following command will plot the time series <code>x</code> and <code>y</code> as deviations from <code>1</code> multiplied by <code>100</code> (see the option <code>'transform='</code>), and the time series <code>z</code> as it is (because of the <code>^</code> symbol at the beginning). The first series will be labeled simply <code>'x'</code>, while the last two series will be labeled <code>'Series y'</code> and <code>'Series z'</code>, respectively.</p>
<pre><code>dbplot(d,qq(2010,1):qq(2015,4), ...
   { &#39;x&#39;, &#39;&quot;Series y&quot; y&#39;, &#39;^&quot;Series z&quot;&#39; }, ...
   &#39;transform=&#39;,@(x) 100*(x-1));</code></pre>
<h4 id="example-1">Example</h4>
<p>The following command will plot the time series <code>x</code> and <code>y</code> as deviations from year 2000; <code>x</code> will be computed as additive deviations (i.e. the base period value will be subtracted from its observations) whereas <code>y</code> will be computed as a multiplicative deviations (i.e. the observations will be divided by the base period value). The last time series <code>z</code> will not be transforme.d</p>
<pre><code>dbplot(d,yy(2000):yy(2010), ...
   { &#39;# x&#39;, &#39;@ y&#39;, &#39;z&#39; }, ...
   &#39;deviationsFrom=&#39;,yy(2000));</code></pre>
<h4 id="example-2">Example</h4>
<p>The following command will plot all time series found in the database that start with <code>'a'</code>.</p>
<pre><code>dbplot(d,rexp(&#39;^a.*&#39;));</code></pre>
<h4 id="example-3">Example</h4>
<p>Create an example database with the following fields: <code>c</code>, <code>ctrend</code>, <code>y</code>, <code>ytrend</code>, <code>k</code>, <code>ktrend</code> (the exact way these series are created is, of course, irrelevant):</p>
<pre><code>range = qq(2000,1):qq(2004,4);
s = struct();
s.c = 1+cumsum( tseries(range,@rand)/10 );
s.ctrend = hpf(s.c);
s.y = 1+cumsum( tseries(range,@rand)/10 );
s.ytrend = hpf(s.y);
s.k = 1+ cumsum( tseries(range,@rand)/10 );
s.ktrend = hpf(s.k);
disp(s);</code></pre>
<p>Plot the individual series against their respective trends, each in its own graph:</p>
<pre><code>dbplot(s,range, ...
    { &#39;[c,ctrend]&#39;, &#39;[y,ytrend]&#39;, &#39;[k,ktrend]&#39; } );</code></pre>
<p>To automate this task, create the list of expressions to be plotted using the standard Matlab function <code>strcat</code>:</p>
<pre><code>list = {&#39;c&#39;,&#39;y&#39;,&#39;k&#39;};
plotList = strcat( &#39;[&#39; , list , &#39;,&#39; , list , &#39;trend]&#39; );
disp(plotList);
dbplot(s,range,plotList);</code></pre>
<p>In the case of some complex transformation(s), e.g.</p>
<pre><code>dbplot(s,range, { ...
    &#39;100*log([c,ctrend])&#39;,  ...
    &#39;100*log([y,ytrend])&#39;, ...
    &#39;100*log([k,ktrend])&#39; } );</code></pre>
<p>use the option <code>'transform='</code> to apply the specified function to all series before they get plotted:</p>
<pre><code>dbplot(s,range, ...
    { &#39;[c,ctrend]&#39;, &#39;[y,ytrend]&#39;, &#39;[k,ktrend]&#39; }, ...
    &#39;transform=&#39;,@(x) 100*log(x) );</code></pre>
<p>If some graphs need to be excluded from <code>'transform='</code>, use a hat <code>^</code> at the beginning of the expression:</p>
<pre><code>dbplot(s,range, ...
    { &#39;[c,ctrend]&#39;, &#39;[y,ytrend]&#39;, &#39;^[k,ktrend]&#39; }, ...
    &#39;transform=&#39;,@(x) 100*log(x) );</code></pre>
<p>Include titles for the individual graphs in double quotes at the beginning of each expression:</p>
<pre><code>dbplot(s,range, { ...
    &#39;&quot;Consumption&quot; [c,ctrend]&#39;, ...
    &#39;&quot;Output&quot; [y,ytrend]&#39;, ...
    &#39;&quot;Capital&quot; [k,ktrend]&#39; } );</code></pre>
<p>or alternatively use the option <code>'captions='</code> to do the same thing:</p>
<pre><code>dbplot(s,range, ...
    { &#39;[c,ctrend]&#39;, &#39;[y,ytrend]&#39;, &#39;[k,ktrend]&#39; }, ....
    &#39;captions=&#39;,{&#39;Consumption&#39;,&#39;Output&#39;,&#39;Capital&#39;} );</code></pre>

</body>
<div class="copyright">IRIS Toolbox. Copyright &copy; 2007-2015 IRIS Solutions Team.</div>
</html>
